package main

import (
	"gin-kitex-gorm/api/handlers"
	"gin-kitex-gorm/api/rpc"
	"gin-kitex-gorm/kitex_gen/user/usersrv"
	"github.com/cloudwego/kitex/client"
	"github.com/gin-gonic/gin"
	"log"
)

func main() {
	// 服务发现
	//re, err := etcd.NewEtcdResolver([]string{"111.230.95.201:10079"})
	//if err != nil {
	//	log.Fatal(err)
	//}

	cli, err := usersrv.NewClient("user",
		//client.WithResolver(re),
		client.WithHostPorts("127.0.0.1:9092"),
	)
	if err != nil {
		log.Fatal(err)
	}

	rpc.UserClient = cli

	r := gin.Default()

	Router(r)

	err = r.Run(":1010")
	if err != nil {
		return
	}
}

func Router(r *gin.Engine) {
	r.POST("/douyin/user/register/", handlers.Register)
	r.POST("/douyin/user/login/", handlers.Login)
}
